package snake;

import java.util.ArrayList;
import java.util.List;

import snake.Player.PlayerStatus;
import snake.Player.PlayerType;
import model.User;

public class GamePackage
{
	private final int x = 40;
	private final int y = 40;

	public enum GameStatus
	{
		WAITING, PLAYING, FINISHED
	}

	private int gameId;
	private List<Player> playersList;

	private int[][] matrix;
	private GameStatus gameStatus = GameStatus.WAITING;
	private int scoreLimit;

	public GamePackage()
	{
		matrix = new int[x][y];
		for (int i = 0; i < x; i++)
		{
			for (int j = 0; j < y; j++)
			{
				matrix[i][j] = 0;
			}
		}
	}

	public void setMatixValue(int value, int x, int y)
	{
		matrix[x][y] = value;
	}

	public int getGameId()
	{
		return gameId;
	}

	public void setGameId(int gameId)
	{
		this.gameId = gameId;
	}

	public int[][] getMatrix()
	{
		return matrix;
	}

	public void setMatrix(int[][] matrix)
	{
		this.matrix = matrix;
	}

	public GameStatus getGameStatus()
	{
		return gameStatus;
	}

	public void setGameStatus(GameStatus gameStatus)
	{
		this.gameStatus = gameStatus;
	}

	public List<Player> getPlayersList()
	{
		return playersList;
	}

	public void setPlayersList(List<User> usersList)
	{

		List<Player> playersList = new ArrayList<>();
		for (int i = 0; i < usersList.size(); i++)
		{
			Player player = new Player();
			player.setId(usersList.get(i).getId());
			player.setStatus(usersList.get(i).getStatus());
			player.setUsername(usersList.get(i).getUsername());

			player.setPlayerStatus(PlayerStatus.ALIVE);
			player.setPlayerType(PlayerType.USER);
			player.setScore(0);
			playersList.add(player);
		}

		this.playersList = playersList;

	}

	public int getScoreLimit()
	{
		return scoreLimit;
	}

	public void setScoreLimit(int scoreLimit)
	{
		this.scoreLimit = scoreLimit;
	}
}
